<!--#include file="../nav/account_top.php" -->
<style type="text/css"> 
/* 特殊处理 */
.main_content_title{
margin-left:0px;
margin-right:0px;
}
/* 购物车商品 */
.combo_name{
font-size: 14px;
font-weight: bold;
margin: 10px auto;
color: #555555;
}
.vegeitem{
border: 1px dashed #CCCCCC;
color: #006600;
float: left;
margin-bottom: 10px;
margin-right: 10px;
padding: 5px 10px;
} 
/* 购物车表格 */
table.carttb{
border-collapse:collapse;
width:100%;
}
table.carttb th{
color:#666666;
border-bottom: 1px solid #CECECE;
text-align:center;
padding:10px;
background-color:#E8EEF1;
}
table.carttb td{
color:#666666;
border-bottom: 1px dotted #CECECE;
text-align:center;
vertical-align:middle;
padding:5px;
}
table.carttb td.l{
text-align:left;
}
table.carttb td.r{
text-align:right;
} 
/* 结算DIv */
table.jstb{
border-collapse:collapse;
width:100%;
color:#666666;
}
table.jstb td{
padding:10px;
text-align:center;
}
table.jstb td.td_title{
text-align:left;
padding-left:10px;
}
table.jstb td.td_val{
text-align:right;
width:150px;
font-weight:bold;
padding-right:20px;
}
.jsdiv{
background-color:#EFEFEF;
padding:20px;
padding-right:10px;
}
</style>
<div class="main_content_main"> 
	<div class="vpage_step">
		<ul class="step_ul">
			<li class="s_1" id="li_s_1">
				<div class="node">
					<span class="bg"></span>
					<p class="text">
						<i>1</i>
						购物车
					</p>
				</div>		
			</li>
			<li class="s_2 on" id="li_s_2">
				<div class="node">
					<span class="bg"></span>
					<p class="text">
						<i>2</i>
						结算订单
					</p>
				</div>		
			</li>
			<li class="s_3" id="li_s_3">
				<div class="node">
					<span class="bg"></span>
					<p class="text">
						<i>3</i>
						购买成功
					</p>
				</div>		
			</li>
		</ul>
	</div> 
	
	
<style type="text/css">
.suc_div{
background-color:#FFFFE3;
border:1px solid #EBDBC5;
color:#333333;
padding:20px 40px;
} 
</style>	
	<div id="success_div" style="display:none">
		<div class="suc_div" style="font-size:14px;">
			<div style="font-size:24px;margin:20px auto;background:url(/misc/images/account/success2.png) top left no-repeat;padding-left:40px">您的订单提交成功，我们将尽快为您审核并安排发货。</div>
			<div style="margin:10px auto">
				订单编号：<span id="suc_ordercode">  </span>
			</div>
			<div style="margin:10px auto">
				支付金额：<span class="red" >￥</span><span class="red" id="suc_trans_total"> </span><span class="red" >元</span>
	 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				当前账户余额：￥<span id="suc_trans_balance"> </span>元
			</div>
			<div style="margin:10px auto">
				赠送积分：<span class="green" id="suc_point_total"> </span><span class="green" >分</span>
	 			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				当前账户积分：<span id="suc_point_balance"> </span>分
			</div>
			<div>
				<button class="btn_blue" onclick="jumpTo('/account_buy')" >继续选菜</button> 
				<span class="gray">或</span>
				<button class="btn_blue" onclick="jumpTo('/account_order')" >查看订单</button> 
			</div>
		</div>
	</div>
	
	<div id="confirm_div" >
		
		
<style type="text/css">
.rec_date{
float:left;
border:1px solid #eee;
background-color:#FFFFFF;
color:#999999;
text-align:center;
padding:10px;
padding-left:25px;
margin:5px;
cursor:pointer;
}
.rec_date_on{
border:1px solid #006600;
color:#006633;
background:url(/misc/images/account/isslt.gif) center left   no-repeat #EBFAEE;
}
</style>
<script type="text/javascript">
function fnSltRecDate(i){
	$('.rec_date').removeClass('rec_date_on');
	$('#rec_date_'+i).addClass('rec_date_on');
}
</script>
		<div class="main_content_title">
			<span>送货日期 & 配送时间段</span>
		</div>
		<table  style="width:100%;border-collapse:collapse">
			<tr>
				<td>
					<?PHP
					foreach($rec_date as $k=>$v){
						if($k==0){
							echo '<div title="'.$v.'" id="rec_date_'.$k.'" onclick="fnSltRecDate('.$k.')"  class="rec_date rec_date_on">'.$v.'</div>';
						}else{
							echo '<div title="'.$v.'" id="rec_date_'.$k.'" onclick="fnSltRecDate('.$k.')"  class="rec_date">'.$v.'</div>';
						}
					}
					?>
				</td>
			</tr> 
			<Tr>
				<td>
					<div style="margin:5px;margin-top:20px">
						<select id="sendtime" class="textBox" name="sendtime">
							<option value="" selected="selected">-- 请选择配送时间段 --</option>
							<?PHP
							foreach($sendtime as $v){
								echo '<option value="'.$v['id'].'">'.$v['val'].'</option>';
							}
							?>
						</select>
					</div>
				</td>
			</Tr>
		</table>
		 	 
		
		<div class="main_content_title">
			<span>商品清单</span> 
		</div> 
		<!--商品表格-->
		<div class="margin10">
			<table class="carttb">
				<thead>
					<Tr>
						<Th style="width:400px;">商品</Th>
						<Th>单价</Th>
						<Th style="width:100px;">数量（套）</Th>
						<Th style="width:150px;">小计</Th>
					</Tr>
				</thead>
				<tbody>
				<?PHP
				$num_total = 0;
				$price_total = 0;
				foreach($rs_cart as $v){//debug::show($v);
					$num_total += $v['nums'];
					$price_total += $v['price_total'];
					echo '
					<tr class="cart_tr" id="cart_tr_'.$v['id'].'" price="'.$v['price'].'" myid="'.$v['id'].'" >
						<td class="l" >
							<div class="combo_name">'.$v['combo_name'].'</div>
							<div class="combo_veges">';
					if($v['combo_type'] == '1'){
						foreach($v['cart_item'] as $val){
							echo '
								<div class="vegeitem">
									'.$val['vege_name'].'
									<span> '.$val['vege_num'].' 份</span>
								</div>';
						}
					}else{
						foreach($v['combo_item'] as $val){
							echo '
								<div class="vegeitem">
									'.$val['vege_name'].'
									<span> '.$val['vege_num'].' 份</span>
								</div>';
						}
					}
					echo '
								<div class="clear"></div>
							</div>
						</td>
						<td  >
							￥'.$v['price'].'
						</td>
						<td>
							'.$v['nums'].'
						</td>
						<td style="font-weight:;text-align:right;padding-right:20px;" >
							￥<span id="price_total_'.$v['id'].'">'.func::fnDec($v['price_total'],2).'
						</td>
					</tr>';
				}
				?>
				</tbody>
			</table>
		</div> 
		
		
		
		
		<div class="main_content_title">
			<span>结算信息</span>
		</div>
		<table class="jstb">
			<tr style="border-bottom:1px solid #CCCCCC;">
				<td class="td_title"  >商品总计：</td>
				<td class="td_val" style="font-size:15px;">￥{func::fnDec($price_total,2)}</td>
			</tr>
			<tr>
				<td class="td_title"  >运费：</td>
				<td class="td_val" style="font-size:15px;">￥{func::fnDec($yunfee,2)}</td>
			</tr>
		</table>
		<div class="jsdiv">
			<div style="margin:10px;text-align:right">
				<span style="font-size:14px;font-weight:bold;">总计</span>（含运费）：<span style="font-size:16px;font-weight:bold;color:#FF3333">￥{func::fnDec(($price_total+$yunfee),2)}</span>
			</div>
			<div style="margin:10px;text-align:right;"> 
				<a style="float:left;color:#999999;"  href="/account_cart/index">返回购物车</a>
				<button class="btn_red" onclick="fnConfirmIt()" id="btn_confirm" >确认无误，下订单</button> 
			</div>
		</div>	
		
		
		
	</div>
	
<style type="text/css">
.alertdiv{
background-color:#FFFFE3;
border:1px solid #EBDBC5;
color:#333333;
padding:20px 40px;
margin:5px auto;
display:none;
}
</style>	
	<div class="alertdiv" id="nomoneydiv">
		您当前账户余额 <span class="red">￥{$balance}</span> 不足以支付当前订单，请先进行 <button class="btn_green" onclick="jumpTo('/account_pay/pay')">在线充值</button>
	</div>
	<div  style="height:30px;line-height:1px"></div>
</div>
<script type="text/javascript">
var rs_cart = {json_encode($rs_cart)};
var fenshu = {$fenshu};
var pricetotal = {$pricetotal};
var yunfee = {$yunfee};
var balance = {$balance};
var url_submit = '/account_cart/submitorder';
$().ready(function(){
	if(balance < (pricetotal+yunfee)){
		$('#nomoneydiv').show('slow');
		$('#btn_confirm').addClass('btn_gray').removeClass('btn_red');
	}
});
function fnConfirmIt(){
	if(balance < (pricetotal+yunfee)){
		ymPrompt.alert({message:'您的账户余额不足，请先进行充值',handler:function(){
			//jumpTo('/account_pay/pay');
		}});
		return false;
	}
	if( $('#sendtime').val() == ''){
		ymPrompt.alert({message:'请选择配送时间段',handler:function(){
			$('#sendtime').focus();
		}});
		return false;
	}
	fnConfirm({
		str:"确认提交订单？",
		func_true:function(e){
			fnLoading('正在提交订单');
			$('button').attr('disabled','disabled');
			$.post(
				url_submit,
				{
					rec_date:$('.rec_date_on').attr('title'),
					sendtime:$('#sendtime').val()
				},
				function(e){
					fnLoadingEnd();
					$('button').attr('disabled','');
					var ok = errorHandler(e);
					if(ok && ok.success=="1"){　 
						$('#li_s_2').removeClass('on');
						$('#li_s_3').addClass('on');
						$('#confirm_div').hide();
						$('#success_div').show();
						
						$('#suc_ordercode').html(ok.ordercode);
						$('#suc_trans_total').html(ok.trans_total);
						$('#suc_trans_balance').html(ok.trans_balance);
						$('#suc_point_total').html(ok.point_total);
						$('#suc_point_balance').html(ok.point_balance);
						  
						$('#suc_a').attr('href',$('#suc_a').attr('href')+ok.order_id);
						fnToTop();
					}
				}
			);
		}
	});
}
</script>
<!--#include file="../nav/account_bottom.php" -->